package com.uzai.console.web.mini;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.dto.BaseDto;
import com.uzai.console.dto.mini.deviceminiinfo.*;
import com.uzai.console.jsonvo.mini.AccountBasicInfo;
import com.uzai.console.service.mini.DeviceMiniInfoService;
import com.uzai.console.vo.mini.deviceminiinfo.ComponentAuthVo;
import com.uzai.console.vo.mini.deviceminiinfo.DeviceMiniInfoVo;
import com.uzai.console.vo.mini.deviceminiinfo.FastRegisterAuthVo;
import com.uzai.console.vo.mini.deviceminiinfo.WxpubSelectKeyVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 小程序授权管理
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "小程序授权管理",tags = "微信小程序|小程序授权管理")
@ApiSort(7)
@RestController
public class DevcieMiniInfoController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(DevcieMiniInfoController.class);

    @Autowired
    private DeviceMiniInfoService deviceMiniInfoService;

    @ApiOperation(value = "分页查询小程序授权列表", notes = "分页查询小程序授权列表", response = DeviceMiniInfoVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/deviceMiniInfo/findByPage")
    public Object fingDeviceMiniInfoByPage(@RequestBody DeviceMiniInfoQuery deviceMiniInfoQuery){
        return deviceMiniInfoService.findDeviceMiniInfoByPage(deviceMiniInfoQuery);
    }

    @ApiOperation(value = "查询小程序授权详情", notes = "查询小程序授权详情", response = DeviceMiniInfoVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/deviceMiniInfo/findById")
    public Object fingDeviceMiniInfoById(@RequestBody DeviceMiniInfoIdDto deviceMiniInfoIdDto){
        return deviceMiniInfoService.findDeviceMiniInfoById(deviceMiniInfoIdDto);
    }

    @ApiOperation(value = "小程序授权复用公众号主体快速注册URL", notes = "小程序授权复用公众号主体快速注册url", response = FastRegisterAuthVo.class)
    @ApiOperationSupport(order = 3)
    @PostMapping("/deviceMiniInfo/fastregister/createUrl")
    public Object fastregisterCreateUrl(@RequestBody FastregisterCreateUrlDto fastregisterCreateUrlDto){
        return deviceMiniInfoService.fastregisterCreateUrl(fastregisterCreateUrlDto);
    }

    @ApiOperation(value = "查询小程序授权需要的所有的公众号列表信息-", notes = "查询小程序授权需要的所有的公众号列表信息", response = WxpubSelectKeyVo.class)
    @ApiOperationSupport(order = 4)
    @PostMapping("/deviceMiniInfo/findWxpubList")
    public Object findWxpubList(@RequestBody BaseDto baseDto){
        return deviceMiniInfoService.findWxpubList(baseDto);
    }

    @ApiOperation(value = "小程序授权第三方平台授权URL（公众号和小程序授权公用）", notes = "小程序授权第三方平台授权URL（公众号和小程序授权公用）", response = ComponentAuthVo.class)
    @ApiOperationSupport(order = 5)
    @PostMapping("/deviceMiniInfo/auth/createUrl")
    public Object authCreateUrl(@RequestBody AuthCreateUrlDto componentAuthDto){
        return deviceMiniInfoService.authCreateUrl(componentAuthDto);
    }

    @ApiOperation(value = "小程序授权支付设置", notes = "小程序授权支付设置", response = Boolean.class)
    @ApiOperationSupport(order = 6)
    @PostMapping("/deviceMiniInfo/payinfo/set")
    public Object setPayinfo(@RequestBody SetPayInfoDto setPayInfoDto){
        deviceMiniInfoService.setPayinfo(setPayInfoDto);
        return true;
    }

    @ApiOperation(value = "下载小程序二维码", notes = "下载小程序二维码", response = Object.class)
    @ApiOperationSupport(order = 7)
    @PostMapping("/deviceMiniInfo/getUnlimitedQRCode")
    public Object getUnlimitedQRCode(@RequestBody DeviceMiniInfoIdDto deviceMiniInfoIdDto) {
        return deviceMiniInfoService.getUnlimitedQRCode(deviceMiniInfoIdDto);
    }

    @ApiOperation(value = "小程序订阅消息设置", notes = "小程序订阅消息设置", response = Boolean.class)
    @ApiOperationSupport(order = 8)
    @PostMapping("/deviceMiniInfo/msgTemplate/set")
    public Object setMsgTemplate(@RequestBody SetMsgTemplateDto setMsgTemplateDto){
        deviceMiniInfoService.setMsgTemplate(setMsgTemplateDto);
        return true;
    }

    @ApiOperation(value = "获取小程序绑定基本信息", notes = "获取小程序绑定基本信息", response = AccountBasicInfo.class)
    @ApiOperationSupport(order = 9)
    @PostMapping("/deviceMiniInfo/getAccountBasicInfo")
    public Object getAccountBasicInfo(@RequestBody DeviceMiniInfoIdDto deviceMiniInfoIdDto){
        return deviceMiniInfoService.getAccountBasicInfo(deviceMiniInfoIdDto);
    }

    @ApiOperation(value = "删除小程序授权", notes = "删除小程序授权", response = DeviceMiniInfoVo.class)
    @ApiOperationSupport(order = 9)
    @PostMapping("/deviceMiniInfo/delete")
    public Object deleteDeviceMiniInfo(@RequestBody DeviceMiniInfoIdDto deviceMiniInfoIdDto){
        deviceMiniInfoService.deleteDeviceMiniInfo(deviceMiniInfoIdDto);
        return true;
    }
}
